package com.woniu.humanresource.service.impl;

import com.woniu.humanresource.dao.TrainingDemandDao;
import com.woniu.humanresource.entity.Department;
import com.woniu.humanresource.entity.PageBean;
import com.woniu.humanresource.entity.TrainingDemand;
import com.woniu.humanresource.service.TrainingDemandService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TrainingDemandServiceImpl implements TrainingDemandService {

    @Resource
    TrainingDemandDao demandDao;

    @Override
    public PageBean<TrainingDemand> selectTrainingDemandCondition(TrainingDemand demand, int pageIndex, int pageSize) {
        List<TrainingDemand> trainingDemands = demandDao.selectTrainingDemandCondition(demand, pageIndex, pageSize);
        PageBean<TrainingDemand> pageBean = new PageBean<>();
        pageBean.setBeanList(trainingDemands);
        pageBean.setPageSize(pageSize);
        pageBean.setPageIndex(pageIndex);
        pageBean.setTotalRecord(demandDao.selectTrainingDemandConditionCount(demand));
        return pageBean;
    }

    @Override
    public void deleteTrainingDemand(int did) {
        demandDao.deleteTrainingDemand(did);
    }

    @Override
    public void addTrainingDemand(TrainingDemand demand) {
        demandDao.insertTrainingDemand(demand);
    }

    @Override
    public List<Department> getDep() {
        List<Department> departments = demandDao.selectDep();
        return departments;
    }

    @Override
    public void updateTrainingDemand(TrainingDemand demand) {
        demandDao.updateTrainingDemand(demand);
    }
}
